using System.Diagnostics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input.Touch;
using Rocuna.Controls.Shapes;
using Rocuna.Core;
using Rocuna.GameEngine;
using Rocuna.GameEngine.Extension.WP7.Controls;
using Rocuna.GameEngine.Extension.WP7.EventArgs;
using Rocuna.GameEngine.Extension.WP7.Graphics;
using Rocuna.GameEngine.Extension.WP7.Input.Constants;
using Rocuna.GameEngine.Graphics;
using Rocuna.GameEngine.Graphics.Cameras;
using Rocuna.GameEngine.Graphics.Components;
using Rocuna.GameEngine.Graphics.Terrain;
using Rocuna.GameEngine.Input;
using Rocuna.GameEngine.State.Screens;
using Rocuna.GameEngine.Extension;

namespace POCGame.Screens
{
    public class Level1 : GameScreen
    {
        public Level1(Game game)
            : base(game)
        {
            LoadingScreen = new LoadingScreen(Game);
        }

        public RocunaModel Dude { get; set; }

        public Matrix[] Transforms { get; set; }

        public Camera RenderingCamera { get; set; }

        public Joystick Joystick { get; set; }

        public SkyBox SkyBox { get; set; }

        public TerrainComponent TerrainComponent { get; set; }

        public BillBoard BillBoard { get; set; }

        public SplashScreen LoadingScreen { get; set; }

        private bool _loadingStarted = false;

        protected override void LoadContent()
        {
            base.LoadContent();
        }

        public override void Initialize()
        {
            LoadAdditionalContent();
            base.Initialize();
        }

        private void LoadAdditionalContent()
        {
            _loadingStarted = true;
            SkyBox = new SkyBox(Game.Content.Load<TextureCube>("b"), Game);
            TerrainComponent = new TerrainComponent(Game, "HeightMap");
            //SkyBox = new SkyBoxTemp(Game.Content.Load<TextureCube>("b"), Game);
            Joystick =
                new Joystick(Game) { Foreground = Game.Content.Load<Texture2D>("Joystick"), Border = new Circle(700, 400, 70) };
            Joystick.RegisterDefaultBehavior();
            Dude = new RocunaModel(Game.Content.Load<Model>("box"), Vector3.Zero, Vector3.Zero, new Vector3(10f), Game);
            BillBoard = new BillBoard(Game.Content.Load<Texture2D>("tree"), Game);
            Components.Add(BillBoard);
            Components.Add(Joystick);
            Components.Add(Dude);
            Components.Add(SkyBox);
            Components.Add(TerrainComponent);
            //Dude.SetModelEffect(Game.Content.Load<Effect>("SimpleEffect"), true);););););
            base.LoadContent();
        }

        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
        }

        public override void Update(GameTime gameTime)
        {
            RenderingCamera = (Game.Services.GetService(typeof(GraphicManager)) as GraphicManager).CurrentCamera;
            base.Update(gameTime);
        }

        /// <summary>
        /// Activates this instance.
        /// </summary>
        public override void Activate()
        {
            base.Activate();
        }

        public override void Deactivate()
        {
            base.Deactivate();
        }
    }
}